from pylons import config
import sqlalchemy as sqla
from sqlalchemy.orm import mapper, relation
from sqlalchemy.orm import scoped_session,sessionmaker

Session = scoped_session(sessionmaker(autoflush=True, transactional=True,
                                      bind=config['pylons.g'].sa_engine))


metadata = sqla.MetaData()
caps_table = sqla.Table('caps', metadata,
    sqla.Column('id', sqla.Integer, primary_key=True, autoincrement=True),
    sqla.Column('origin', sqla.String(255)),
    sqla.Column('title', sqla.String(255)),
    sqla.Column('url', sqla.String(255)),
    sqla.Column('uuid', sqla.String(255)),
    sqla.Column('timeout', sqla.DateTime()),
    )


class Capability(object):
    def __str__(self):
        return self.title+" for "+self.origin

mapper(Capability, caps_table)

